﻿@model IndoReputation.Models.BusinessObject.Collections.MediaCategoryList

@{
    ViewBag.Title = "List Media Category";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>List Media Category</h2>
<div class="grid-main">
    @(Html.Telerik().Grid(Model)
        .Name("Grid")
        .DataKeys(keys =>
        {
            keys.Add(p => p.ID);
        })
            .ToolBar(toolbar => toolbar.Template(@<text>@item.CustomCommandToolBarButton("insertnew", "Add new Media category", "Add", "MediaCategory", null, false, GridButtonType.Text)</text>))
        .Columns(columns =>
        {
            columns.Bound(o => o.No).Width(50);
            columns.Bound(o => o.Name).Width(150);
            columns.Bound(o => o.IsNewspaper).ClientTemplate("<# if (IsNewspaper) { #> <img alt='<#= IsNewspaper #>' src='" + Url.Content("~/Content/img/accept.png") + "'/>" + "<# } else { #> <img alt='<#= IsNewspaper #>' src='" + Url.Content("~/Content/img/remove.png") + "' /> <# } #>").Filterable(true)      
                .Title("Newspaper").Width(100).HtmlAttributes(new { style = "text-align: center" });
            columns.Bound(o => o.IsTV).ClientTemplate("<# if (IsTV) { #> <img alt='<#= IsTV #>' src='" + Url.Content("~/Content/img/accept.png") + "'/>" + "<# } else { #> <img alt='<#= IsTV #>' src='" + Url.Content("~/Content/img/remove.png") + "' /> <# } #>").Filterable(true)
                .Title("Television").Width(100).HtmlAttributes(new { style = "text-align: center" });
            columns.Bound(o => o.IsRadio).ClientTemplate("<# if (IsRadio) { #> <img alt='<#= IsRadio #>' src='" + Url.Content("~/Content/img/accept.png") + "'/>" + "<# } else { #> <img alt='<#= IsRadio #>' src='" + Url.Content("~/Content/img/remove.png") + "' /> <# } #>").Filterable(true)
                .Title("Radio").Width(100).HtmlAttributes(new { style = "text-align: center" });
            columns.Bound(o => o.IsOnlineNews).ClientTemplate("<# if (IsOnlineNews) { #> <img alt='<#= IsOnlineNews #>' src='" + Url.Content("~/Content/img/accept.png") + "'/>" + "<# } else { #> <img alt='<#= IsOnlineNews #>' src='" + Url.Content("~/Content/img/remove.png") + "' /> <# } #>").Filterable(true)
                .Title("Online News").Width(120).HtmlAttributes(new { style = "text-align: center" });
            columns.Bound(o => o.IsOnline).ClientTemplate("<# if (IsOnline) { #> <img alt='<#= IsOnline #>' src='" + Url.Content("~/Content/img/accept.png") + "'/>" + "<# } else { #> <img alt='<#= IsOnline #>' src='" + Url.Content("~/Content/img/remove.png") + "' /> <# } #>").Filterable(true)
                .Title("Is Online").Width(100).HtmlAttributes(new { style = "text-align: center" });
            columns.Bound(o => o.CreateAt).Format("{0:dd/MM/yyyy}").Width(100);
            columns.Command(commands =>
            {
                commands.Custom("viewDetail")
                    .Text("Edit")
                    .DataRouteValues(route => route.Add(o => o.ID).RouteKey("mediaCategoryID"))
                    .Ajax(false)
                    .Action("Edit", "MediaCategory")
                    .HtmlAttributes(new { style = "text-align: center" });
                commands.Delete();
            })
                .Width(220).HtmlAttributes(new { style = "text-align: center" });

        })
        .DataBinding(dataBinding =>
        {
            //dataBinding.Server().Select("Index", "MediaCategory", new { ajax = ViewData["ajax"] });
            dataBinding.Ajax().Select("_Index", "MediaCategory").Enabled((bool)ViewData["ajax"])
                .Delete("_DeleteAjaxEditing", "MediaCategory");
        })
        .Selectable()
        .Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
        .Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
        .Pageable(paging => paging.PageSize(20).Enabled((bool)ViewData["paging"]))
        .Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
        .Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
        .Footer((bool)ViewData["showFooter"])
        .ClientEvents(events => events.OnComplete("Assessments_onComplete"))
        )
</div>
<script src="@Url.Content("~/Scripts/indo.common.js")" type="text/javascript"></script>